package com.netty.junjie;

import com.netty.junjie.socket.server.NettyBufServer;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

import javax.annotation.Resource;

/**
 * *
 * NettyApplication 启动类
 *
 * @author JunJie
 * @Date 2020/07/13 07:13
 **/
@SpringBootApplication
public class NettyApplication extends SpringBootServletInitializer implements CommandLineRunner {

    @Resource
    private NettyBufServer nettyBufServer;

    public static void main(String[] args) {
        SpringApplication.run(NettyApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        this.setRegisterErrorPageFilter(false); // 错误页面有容器来处理，而不是SpringBoot
        return builder.sources(NettyApplication.class);
    }

    @Override
    public void run(String... args) throws Exception {
        nettyBufServer.bind();
    }
}